<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

 <link rel="STYLESHEET" type="text/css" href="css/dhtmlxgrid.css">
     <script src="js/dhtmlxcommon.js"></script>
     <script src="js/dhtmlxgrid.js"></script>
     <script src="js/dhtmlxgridcell.js"></script>
     
     <script src="js/jquery-1.5.min.js"></script>
     
     <link href="css/uni-form.css" media="screen" rel="stylesheet"/>
    <link href="css/demo.css" media="screen" rel="stylesheet"/>
    <link href="css/default.uni-form.css" id="formStyle" title="Default Style" media="screen" rel="stylesheet"/>
     

<script>
	var mygrid;
	function doInitGrid(){
	 mygrid = new dhtmlXGridObject('mygrid_container');
	 mygrid.setImagePath("css/imgs/");
	 mygrid.setHeader('<s:text name="loginName" />,<s:text name="userName" />,<s:text name="eMail" />');
	 mygrid.setInitWidths("150,250,*");
	 mygrid.setColAlign("left,left,left")
	 mygrid.setSkin("light");
	 mygrid.setColSorting("str,str,str");
	 mygrid.setColTypes("ed,ed,ed");
	 mygrid.attachEvent("onRowSelect",doOnRowSelected);
	 mygrid.init();
	 mygrid.loadXML("getUserXmldata");
	 
	 
	}
	
	$(document).ready(function(){
		
		doInitGrid();
	});
	
	function doOnRowSelected(id){
		$('#selectedUserId').val(id);
		
	}
	
	function formSubmit(action){
		
		
		if(action == "modifyUser" ||
			action =="deleteUser"){
				if($('#selectedUserId').val() == "0"){
					alert('<s:text name="userList.noselect" />');
					return false;
				}
		}
		
		$('#userForm').attr("action", action);
		
		
		
		$('#userForm').submit();
	}
		

</script>
</head>
<body>
 <form id="userForm" class="uniForm">
	<div id="mygrid_container" style="width:600px;height:300px;"></div>
	
	
		 <div class="buttonHolder">
		 <button type="button" class="primaryAction" onclick="formSubmit('createUser');"><s:text name="createUser"></s:text></button>
	       <button type="button" class="primaryAction" onclick="formSubmit('modifyUser');"><s:text name="modifyUser"></s:text></button>
	        <button type="button" class="primaryAction" onclick="formSubmit('deleteUser');"><s:text name="deleteUser"></s:text></button>
	      </div>
	      
	      <s:hidden name="selectedUserId" value="0"></s:hidden>
	 </form>     
</body>
</html>